<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>Show User</title>
  <g:javascript library="scriptaculous" />
</head>
<body>
<div class="nav">
  <g:ifAnyGranted role="ROLE_ADMIN">
  <span class="menuButton"><g:link class="list" action="list">User List</g:link></span>
  <span class="menuButton"><g:link class="create" action="create">New User</g:link></span>
  </g:ifAnyGranted>
</div>
<div class="body">
  <h1>Show User</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <div class="dialog">
    <h3>Login Details</h3>
    <table>
      <tbody>

      <tr class="prop">
        <td valign="top" class="name">Username:</td>

        <td valign="top" class="value">${fieldValue(bean: userInstance, field: 'username')} <g:link controller="profile" action="show" id="${userInstance?.profile?.id}">(User Profile)</g:link></td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Enabled:</td>

        <td valign="top" class="value">${fieldValue(bean: userInstance, field: 'enabled')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Email Addresses:</td>
        <td valign="top" style="text-align:left;" class="value">
          <table style="cellpadding:0; cellspacing:0;">
            <g:each var="emailAddress" status="i" in="${userInstance.emailAddresses}">
              <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>
                  <g:link controller="emailAddress" action="edit" id="${emailAddress.id}">${emailAddress}</g:link>
                </td>
                <td>
                <g:if test="${!emailAddress?.isMain}">
                  <g:form controller="emailAddress" action="setAsMain">
                    <input type="hidden" name="id" value="${emailAddress?.id}"/>
                    <g:actionSubmit value="Set as Main" action="setAsMain" class="emailButton"/>
                  </g:form>
                </g:if>
                <g:else>&nbsp;</g:else>
                </td>
                <td>
                  <g:form controller="emailAddress" action="delete">
                  <input type="hidden" name="id" value="${emailAddress?.id}"/>
                  <g:actionSubmit onclick="return confirm('Are you sure?');" value="Delete" class="emailButton"/>
                </g:form>
                </td>
              </tr>
            </g:each>
            <tr class="prop">
              <td valign="top" class="value" colspan="3">
                <a href="<g:createLink controller='emailAddress' action='create'/>/?user.id=${userInstance?.id}">Add Email Address</a>
              </td>

            </tr>
          </table>
        </td>
      </tr>

      </tbody>
    </table>
    <h3>My Alerts</h3>
    <table>
      <tbody>

      <tr class="prop">
        <td valign="top" class="name">Receive Event Alerts by Mail:</td>

        <td valign="top" class="value">
          <g:form>
            <input type="hidden" name="id" value="${userInstance?.id}"/>
            <input type="hidden" name="version" value="${userInstance?.version}"/>
            <g:actionSubmit class="toggleButton" value="${userInstance.eventAlert ? 'Enabled.' : 'Disabled.' }" action="toggleEvent"/>
          </g:form>
        </td>
      </tr>

      <tr class="prop">
        <td valign="top" class="name">Receive Daily Mail Digest:</td>

        <td valign="top" class="value">
          <g:form>
            <input type="hidden" name="id" value="${userInstance?.id}"/>
            <input type="hidden" name="version" value="${userInstance?.version}"/>
            <g:actionSubmit class="toggleButton" value="${userInstance.dailyDigest ? 'Enabled.' : 'Disabled.' }" action="toggleDailyMailDigest"/>
          </g:form>
        </td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Receive Weekly Mail Digest:</td>

        <td valign="top" class="value">
          <g:form>
            <input type="hidden" name="id" value="${userInstance?.id}"/>
            <input type="hidden" name="version" value="${userInstance?.version}"/>
            <g:actionSubmit class="toggleButton" value="${userInstance.weeklyDigest ? 'Enabled.' : 'Disabled.' }" action="toggleWeeklyMailDigest"/>
          </g:form>
        </td>

      </tr>

      </tbody>
    </table>
    <h3>My Events</h3>
    <table>
      <tbody>

      <tr class="prop">

        <td colspan="2" valign="top" style="text-align:left;" class="value">
          <ul>
            <g:each var="e" in="${userInstance.events}">
              <li><g:link controller="event" action="show" id="${e.id}">${e?.encodeAsHTML()}</g:link></li>
            </g:each>
          </ul>
        </td>
      </tr>
      <tr>
        <td colspan="2" valign="top" style="text-align:left;" class="value">
          <a id="addEvent" href="<g:createLink controller='event' action='create'/>/?user.id=${userInstance?.id}" title="You may add events to your user profile.<br/>An event could be e.g. a birthday.<br/>Depending on your settings, the event will then be announced<br/> within the MoTSangria Activity Log and via Mail to all subscribed members.">Add New Event</a>
          <richui:tooltip id="addEvent"/>
        </td>
      </tr>
      </tbody>
    </table>
    <h3>My RSS Feeds</h3>
    <table>
      <tbody>

      <g:each var="f" status="j" in="${userInstance.feedInfos}">
      <tr class="${(j % 2) == 0 ? 'odd' : 'even'}">  
        <td valign="top" style="text-align:left;" class="value">
          <g:link controller="feedInfo" action="edit" id="${f.id}">${f?.encodeAsHTML()}</g:link>
        </td>
        <td valign="top" style="text-align:left;" class="value">
          <g:form controller="feedInfo" action="updateFeeds">
            <input type="hidden" name="id" value="${f?.id}"/>
            <span class="emailButton"><g:actionSubmit class="emailButton" value="Reload Feed" action="updateFeed" /></span>
          </g:form>
        </td>
        <td valign="top" style="text-align:left;" class="value">
          <g:form controller="feedInfo" action="edit">
            <input type="hidden" name="id" value="${f?.id}"/>
            <g:actionSubmit value="Edit" class="emailButton"/>
          </g:form>
        </td>
        <td valign="top" style="text-align:left;" class="value">
          <g:form controller="feedInfo" action="delete">
            <input type="hidden" name="id" value="${f?.id}"/>
            <g:actionSubmit onclick="return confirm('Are you sure?');" value="Delete" class="emailButton"/>
          </g:form>
        </td>
      </tr>
      </g:each>
      <tr>
        <td colspan="4" valign="top" style="text-align:left;" class="value">
          <a id="addFeed" href="<g:createLink controller='feedInfo' action='create'/>/?user.id=${userInstance?.id}" title="You may add RSS or Atom Feeds to <br/> your user profile, e.g. your twitter message feed.<br/> Each of feed will be checked regularly and new <br/>entries will be automatically posted to the MoTSangria Activity Log.">Add New Feed</a>
          <richui:tooltip id="addFeed"/>
        </td>
      </tr>

      </tbody>
    </table>
  </div>
  <div class="buttons">
    <g:form>
      <input type="hidden" name="id" value="${userInstance?.id}"/>
      <span class="button"><g:actionSubmit class="edit" value="Edit"/></span>
      <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
      <span class="button"><g:actionSubmit class="edit" value="Send Test Mail" action="sendTestMail"/></span>
    </g:form>
  </div>
</div>
</body>
</html>
